package com.dreamthen.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;

/**
 * @Author zengms
 * @Date 2023-10-22 16:11:30
 **/
@Configuration
@ComponentScan(basePackages = "com.dreamthen")
@PropertySource("classpath:dbConfig.properties")
@Import({IocConfig.class,DbConfig.class}) // <import resource="classpath:ioc.xml"/>
public class AppConfig {

    @Value("${mysql.userName}")
    private String userName;

    @Value("${mysql.passWord}")
    private String passWord;

    @Value("${mysql.url}")
    private String url;

    @Value("${mysql.driverClassName}")
    private String driverClassName;


    /*
    <bean class="com.alibaba.druid.pool.DruidDataSource" id="dataSource">
        <property name="username" value="${mysql.userName}"></property>
        <property name="password" value="${mysql.passWord}"></property>
        <property name="url" value="${mysql.url}"></property>
        <property name="driverClassName" value="${mysql.driverClassName}"></property>
    </bean>
     */
    @Bean //<bean class="com.alibaba.druid.pool.DruidDataSource" id="dataSource">
    public DruidDataSource dataSource(){
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUsername(userName);
        dataSource.setPassword(passWord);
        dataSource.setUrl(url);
        dataSource.setDriverClassName(driverClassName);
        return dataSource;
    }



}
